/*! \mainpage libcytovision documentation file
 * \author Gustavo Junior Alves
 * \date 2003-2007
 * \warning Still on alpha stage
 *
 * \section intro_sec Introduction
 *
 * Cytovision is a software developed by Applied Images for cariotype analises
 * This library provide a way to directly access the generated case files.
 *
 * \section install_sec Installation
 *
 * \subsection sources Getting the sources
 *
 * \code
 * svn checkout http://svn.gjalves.com.br/svnroot/genetica/cytovision/libcytovision
 * \endcode
 *
 * \subsection compiling Compiling
 *
 * To compile and install the library package, use as usual:
 *
 * \code
 * make
 *
 * make install
 * \endcode
 *
 * If you wish to install in another dir, use:
 *
 * \code
 * make install DESTDIR=<dir>
 * \endcode
 *
 * \todo Freeze functions for this version
 * \todo Functions for manipulate karyotype
 * \todo Functions for manipulate image files
 */

#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include "libcytovision.h"

/*! \brief Scan all cases and execute func() for each one
 * \param path Directory where the case can be found
 * \param func Pointer to function to be executed for each case
 * The scan will check only for valid cases
 * \retval 0 Ok
 * \retval -1 Error opening CASEDIR
*/

int cytovision_scancases(char *path,void func(char *path,struct dirent *)) {
  DIR *d;
  struct dirent *ent;

  if((d=opendir(path))==NULL) {
    perror(path);
    return -1;
  }
  while((ent=readdir(d))) {
    if(strcmp(ent->d_name,".")==0) continue;
    if(strcmp(ent->d_name,"..")==0) continue;
    if(ent->d_type!=DT_DIR) continue;
    func(path,ent);
  }
  closedir(d);
  return 0;
}
